package com.wl.jetpackdemo.chat

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.othershe.combinebitmap.CombineBitmap
import com.othershe.combinebitmap.layout.WechatLayoutManager
import com.wl.jetpackdemo.R
import com.wl.jetpackdemo.base.widget.RoundImageView

/**
 *
 * Created by wangliang on 2021/2/19.
 */
class MessageSessionAdapter : BaseQuickAdapter<MessageSession, BaseViewHolder>(R.layout.item_message_index) {
    private val IMG_URL_ARR = arrayOf(
        "http://img.hb.aicdn.com/eca438704a81dd1fa83347cb8ec1a49ec16d2802c846-laesx2_fw658",
        "http://img.hb.aicdn.com/729970b85e6f56b0d029dcc30be04b484e6cf82d18df2-XwtPUZ_fw658",
        "http://img.hb.aicdn.com/85579fa12b182a3abee62bd3fceae0047767857fe6d4-99Wtzp_fw658",
        "http://img.hb.aicdn.com/2814e43d98ed41e8b3393b0ff8f08f98398d1f6e28a9b-xfGDIC_fw658",
        "http://img.hb.aicdn.com/a1f189d4a420ef1927317ebfacc2ae055ff9f212148fb-iEyFWS_fw658",
        "http://img.hb.aicdn.com/69b52afdca0ae780ee44c6f14a371eee68ece4ec8a8ce-4vaO0k_fw658",
        "http://img.hb.aicdn.com/9925b5f679964d769c91ad407e46a4ae9d47be8155e9a-seH7yY_fw658",
        "http://img.hb.aicdn.com/e22ee5730f152c236c69e2242b9d9114852be2bd8629-EKEnFD_fw658",
        "http://img.hb.aicdn.com/73f2fbeb01cd3fcb2b4dccbbb7973aa1a82c420b21079-5yj6fx_fw658"
    )

    override fun convert(holder: BaseViewHolder, item: MessageSession) {
        //TODO 设置
        var iv = holder.getView<RoundImageView>(R.id.iv_avatar)
        iv.setImageResource(0)
        if(item.isGroup) {
            CombineBitmap.init(context).setLayoutManager(WechatLayoutManager())
                .setSize(88)
                .setGap(1)
                .setUrls(*IMG_URL_ARR)
                .setImageView(iv)
                .build()
        } else {
            iv.setImageResource(R.drawable.avatar_1_raster)
        }
    }
}